def powerset(nums):
    sets=[[]]
    for num in nums:
        newsets=[]
        for x in sets:
            newsets.append(x+[num])#列表拼接 + 的作用
        sets.extend(newsets)
    return sets
if __name__=='__main__':
    test=[
        [1,3,4],
        [2,3],
        [0],
        [4,5,6,7]
    ]
    for nums in test:
        result=powerset(nums)
        print(f'输出{nums}')
        print(f'输出{result}')
        print(f"子集数量: {len(result)} (2^{len(nums)} = {2**len(nums)})")
